using IGeekFan.AspNetCore.Knife4jUI;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using NLog.Web;
using System.Reflection;
using Traceability.APP;
using Traceability.Infrastructure;
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(x =>
{
    var path = AppDomain.CurrentDomain.BaseDirectory + "Traceability.APP.xml";
    x.IncludeXmlComments(path, true);
});
builder.Services.AddAutoMapper(typeof(MapperProfiles));
builder.Services.AddDbContext<DataDbContext>(x =>
{
    x.UseSqlServer(builder.Configuration.GetConnectionString("conn"));
});
builder.Services.AddScoped(typeof(IBaseRepository<>), typeof(BaseRepository<>));
builder.Services.AddMediatR(x => x.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()));
builder.Host.UseNLog();
var app = builder.Build();
app.UseCors(x => x.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
// Configure the HTTP request pipeline.
app.UseSwagger();
app.UseStaticFiles();
//app.UseSwaggerUI();
app.UseKnife4UI();

app.UseAuthorization();

app.MapControllers();

app.Run();
